home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / Meshwriter / TestAll / testall.c next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  11.7 KB  |  239 lines

  1. /*
  2. ** ANSI standart includes
  3. */
  4. #include <stdio.h>
  5.  
  6. /*
  7. ** Amiga includes
  8. */
  9.  
  10. /*
  11. ** Amiga libraries includes
  12. */
  13.  
  14. /*
  15. ** Project includes
  16. */
  17. #include </meshlib.h>
  18.  
  19. /************************** test main *******************************/
  20. void main(void) {
  21.   ULONG meshhandle,mathandle1,mathandle2,mathandle3,retval,i,id,dm;
  22.   TOCLColor c,color;
  23.   TOCLVertex v1,v2,v3,vertex;
  24.   STRPTR string=NULL,*array=NULL;
  25.   TOCLFloat fval;
  26.   char buffer[100];
  27.  
  28.   printf("\nTesting all MeshWriter functions\n");
  29.   printf("--------------------------------\n\n");
  30.   
  31.   printf("MWLMeshNew()\t\t\t\t\t\t\t%ld\n",meshhandle = MWLMeshNew());
  32.  
  33.   retval=MWLMeshMaterialAdd(meshhandle,&mathandle1);
  34.   printf("MWLMeshMaterialAdd(meshhandle,&mathandle1)\t\t\t");
  35.   if(retval==RCNOERROR) printf("%ld\n",mathandle1);
  36.   else printf("ERROR %ld\n",retval);
  37.   printf("MWLMeshMaterialNameSet(meshhandle,mathandle1,\"red\")\t\t%ld\n",MWLMeshMaterialNameSet(meshhandle,mathandle1,"red"));
  38.   printf("MWLMeshMaterialNameGet(meshhandle,mathandle1,string)\t\t");
  39.   retval=MWLMeshMaterialNameGet(meshhandle,mathandle1,&string);
  40.   if(retval==RCNOERROR) printf("%s\n",string);
  41.   else printf("%ld\n",retval);
  42.   c.r=255,c.g=0,c.b=0;
  43.   printf("MWLMeshMaterialAmbientColorSet(meshhandle,mathandle1,&color)\t%ld\n",MWLMeshMaterialAmbientColorSet(meshhandle,mathandle1,&c));
  44.   printf("MWLMeshMaterialAmbientColorGet(meshhandle,mathandle1,&color)\t");
  45.   retval=MWLMeshMaterialAmbientColorGet(meshhandle,mathandle1,&color);
  46.   if(retval==RCNOERROR) printf("%d %d %d\n",color.r,color.g,color.b);
  47.   else printf("%ld\n",retval);
  48.   printf("MWLMeshMaterialShininessSet(meshhandle,mathandle1,1)\t\t%ld\n",MWLMeshMaterialShininessSet(meshhandle,mathandle1,1));
  49.   printf("MWLMeshMaterialShininessGet(meshhandle,mathandle1,&floatvalue)\t");
  50.   retval=MWLMeshMaterialShininessGet(meshhandle,mathandle1,&fval);
  51.   if(retval==RCNOERROR) printf("%g\n",fval);
  52.   else printf("%ld\n",retval);
  53.   printf("MWLMeshMaterialTransparencySet(meshhandle,mathandle1,0)\t\t%ld\n",MWLMeshMaterialTransparencySet(meshhandle,mathandle1,0));
  54.   printf("MWLMeshMaterialTransparencyGet(meshhandle,mathandle1,&fval)\t");
  55.   retval=MWLMeshMaterialTransparencyGet(meshhandle,mathandle1,&fval);
  56.   if(retval==RCNOERROR) printf("%g\n",fval);
  57.   else printf("%ld\n",retval);
  58.  
  59.   retval=MWLMeshMaterialAdd(meshhandle,&mathandle2);
  60.   printf("MWLMeshMaterialAdd(meshhandle,&mathandle2)\t\t\t");
  61.   if(retval==RCNOERROR) printf("%ld\n",mathandle2);
  62.   else printf("ERROR %ld\n",retval);
  63.   printf("MWLMeshMaterialNameSet(meshhandle,mathandle2,\"blue\")\t\t%ld\n",MWLMeshMaterialNameSet(meshhandle,mathandle2,"blue"));
  64.   printf("MWLMeshMaterialNameGet(meshhandle,mathandle2,string)\t\t");
  65.   retval=MWLMeshMaterialNameGet(meshhandle,mathandle2,&string);
  66.   if(retval==RCNOERROR) printf("%s\n",string);
  67.   else printf("%ld\n",retval);
  68.   c.r=0,c.g=0,c.b=255;
  69.   printf("MWLMeshMaterialAmbientColorSet(meshhandle,mathandle2,&color)\t%ld\n",MWLMeshMaterialAmbientColorSet(meshhandle,mathandle2,&c));
  70.   printf("MWLMeshMaterialAmbientColorGet(meshhandle,mathandle2,&color)\t");
  71.   retval=MWLMeshMaterialAmbientColorGet(meshhandle,mathandle2,&color);
  72.   if(retval==RCNOERROR) printf("%d %d %d\n",color.r,color.g,color.b);
  73.   else printf("%ld\n",retval);
  74.   printf("MWLMeshMaterialShininessSet(meshhandle,mathandle2,1)\t\t%ld\n",MWLMeshMaterialShininessSet(meshhandle,mathandle2,1));
  75.   printf("MWLMeshMaterialShininessGet(meshhandle,mathandle2,&fval)\t");
  76.   retval=MWLMeshMaterialShininessGet(meshhandle,mathandle2,&fval);
  77.   if(retval==RCNOERROR) printf("%g\n",fval);
  78.   else printf("%ld\n",retval);
  79.   printf("MWLMeshMaterialTransparencySet(meshhandle,mathandle2,0)\t\t%ld\n",MWLMeshMaterialTransparencySet(meshhandle,mathandle2,0));
  80.   printf("MWLMeshMaterialTransparencyGet(meshhandle,mathandle2,&fval)\t");
  81.   retval=MWLMeshMaterialTransparencyGet(meshhandle,mathandle2,&fval);
  82.   if(retval==RCNOERROR) printf("%g\n",fval);
  83.   else printf("%ld\n",retval);
  84.  
  85.   retval=MWLMeshMaterialAdd(meshhandle,&mathandle3);
  86.   printf("MWLMeshMaterialAdd(meshhandle,&mathand3e1)\t\t\t");
  87.   if(retval==RCNOERROR) printf("%ld\n",mathandle3);
  88.   else printf("ERROR %ld\n",retval);
  89.   printf("MWLMeshMaterialNameSet(meshhandle,mathandle3,\"green\")\t\t%ld\n",MWLMeshMaterialNameSet(meshhandle,mathandle3,"green"));
  90.   printf("MWLMeshMaterialNameGet(meshhandle,mathandle3,string)\t\t");
  91.   retval=MWLMeshMaterialNameGet(meshhandle,mathandle3,&string);
  92.   if(retval==RCNOERROR) printf("%s\n",string);
  93.   else printf("%ld\n",retval);
  94.   c.r=0,c.g=255,c.b=0;
  95.   printf("MWLMeshMaterialAmbientColorSet(meshhandle,mathandle3,&color)\t%ld\n",MWLMeshMaterialAmbientColorSet(meshhandle,mathandle3,&c));
  96.   printf("MWLMeshMaterialAmbientColorGet(meshhandle,mathandle3,&color)\t");
  97.   retval=MWLMeshMaterialAmbientColorGet(meshhandle,mathandle3,&color);
  98.   if(retval==RCNOERROR) printf("%d %d %d\n",color.r,color.g,color.b);
  99.   else printf("%ld\n",retval);
  100.   printf("MWLMeshMaterialShininessSet(meshhandle,mathandle3,1)\t\t%ld\n",MWLMeshMaterialShininessSet(meshhandle,mathandle3,1));
  101.   printf("MWLMeshMaterialShininessGet(meshhandle,mathandle3,&fval)\t");
  102.   retval=MWLMeshMaterialShininessGet(meshhandle,mathandle3,&fval);
  103.   if(retval==RCNOERROR) printf("%g\n",fval);
  104.   else printf("%ld\n",retval);
  105.   printf("MWLMeshMaterialTransparencySet(meshhandle,mathandle3,0)\t\t%ld\n",MWLMeshMaterialTransparencySet(meshhandle,mathandle3,0));
  106.   printf("MWLMeshMaterialTransparencyGet(meshhandle,mathandle3,&fval)\t");
  107.   retval=MWLMeshMaterialTransparencyGet(meshhandle,mathandle3,&fval);
  108.   if(retval==RCNOERROR) printf("%g\n",fval);
  109.   else printf("%ld\n",retval);
  110.  
  111.   printf("MWLMeshCopyrightSet(meshhandle,\"Copyright\")\t\t\t%ld\n",MWLMeshCopyrightSet(meshhandle,"Copyright"));
  112.   printf("MWLMeshCopyrightGet(meshhandle,string)\t\t\t\t");
  113.   retval=MWLMeshCopyrightGet(meshhandle,&string);
  114.   if(retval==RCNOERROR) printf("%s\n",string);
  115.   else printf("%ld\n",retval);
  116.     
  117.   printf("MWLMeshNameSet(meshhandle,\"ObjectName\")\t\t\t\t%ld\n",MWLMeshNameSet(meshhandle,"ObjectName"));
  118.   printf("MWLMeshNameGet(meshhandle,string)\t\t\t\t");
  119.   retval=MWLMeshNameGet(meshhandle,&string);
  120.   if(retval==RCNOERROR) printf("%s\n",string);
  121.   else printf("%ld\n",retval);
  122.  
  123.   v1.x=-10,v1.y=-10,v1.z=0;v2.x=10,v2.y=10,v2.z=0;v3.x=-10,v3.y=10,v3.z=0;
  124.   printf("MWLMeshTriangleAdd(meshhandle,1,&v1,&v2,&v3)\t\t\t%ld\n",MWLMeshTriangleAdd(meshhandle,1,&v1,&v2,&v3));
  125.   v1.x=-10,v1.y=-10,v1.z=0;v2.x=10,v2.y=-10,v2.z=0;v3.x=10,v3.y=10,v3.z=0;
  126.   printf("MWLMeshTriangleAdd(meshhandle,2,&v1,&v2,&v3)\t\t\t%ld\n",MWLMeshTriangleAdd(meshhandle,2,&v1,&v2,&v3));
  127.  
  128.   printf("MWLMeshPolygonAdd(meshhandle,0)\t\t\t\t\t%ld\n",MWLMeshPolygonAdd(meshhandle,0));
  129.   printf("MWLMeshPolygonMaterialSet(meshhandle,3)\t\t\t\t%ld\n",MWLMeshPolygonMaterialSet(meshhandle,3));
  130.   v1.x=-10,v1.y=-10,v1.z=0;v2.x=-10,v2.y=10,v2.z=0;v3.x=-20,v3.y=-10,v3.z=0;
  131.   printf("MWLMeshPolygonVertexAdd(meshhandle,&v1)\t\t\t\t%ld\n",MWLMeshPolygonVertexAdd(meshhandle,&v1));
  132.   printf("MWLMeshPolygonVertexAdd(meshhandle,&v2)\t\t\t\t%ld\n",MWLMeshPolygonVertexAdd(meshhandle,&v2));
  133.   printf("MWLMeshPolygonVertexAdd(meshhandle,&v3)\t\t\t\t%ld\n",MWLMeshPolygonVertexAdd(meshhandle,&v3));
  134.  
  135.   printf("MWLMeshNumberOfMaterialsGet(meshhandle)\t\t\t\t%ld\n",MWLMeshNumberOfMaterialsGet(meshhandle));
  136.   printf("MWLMeshNumberOfPolygonsGet(meshhandle)\t\t\t\t%ld\n",MWLMeshNumberOfPolygonsGet(meshhandle));
  137.   printf("MWLMeshNumberOfVerticesGet(meshhandle)\t\t\t\t%ld\n",MWLMeshNumberOfVerticesGet(meshhandle));
  138.  
  139.  
  140.   printf("MWLMeshCameraLightDefaultSet(meshhandle)\t\t\t%ld\n",MWLMeshCameraLightDefaultSet(meshhandle));
  141.  
  142.   printf("MWLMeshCameraPositionGet(meshhandle,&vertex)\t\t\t");
  143.   retval=MWLMeshCameraPositionGet(meshhandle,&vertex);
  144.   if(retval==RCNOERROR) printf("%g %g %g\n",vertex.x,vertex.y,vertex.z);
  145.   else printf("%ld\n",retval);  
  146.   printf("MWLMeshCameraLookAtGet(meshhandle,&vertex)\t\t\t");  
  147.   retval=MWLMeshCameraLookAtGet(meshhandle,&vertex);
  148.   if(retval==RCNOERROR) printf("%g %g %g\n",vertex.x,vertex.y,vertex.z);
  149.   else printf("%ld\n",retval);
  150.   printf("MWLMeshLightPositionGet(meshhandle,&vertex)\t\t\t");
  151.   retval=MWLMeshLightPositionGet(meshhandle,&vertex);
  152.   if(retval==RCNOERROR) printf("%g %g %g\n",vertex.x,vertex.y,vertex.z);
  153.   else printf("%ld\n",retval);
  154.   printf("MWLMeshLightColorGet(meshhandle,&color)\t\t\t\t");
  155.   retval=MWLMeshLightColorGet(meshhandle,&color);
  156.   if(retval==RCNOERROR) printf("%d %d %d\n",color.r,color.g,color.b);
  157.   else printf("%ld\n",retval);
  158.   
  159.   vertex.x=0,vertex.y=0,vertex.z=100;
  160.   printf("MWLMeshCameraPositionSet(meshhandle,&vertex)\t\t\t%ld\n",MWLMeshCameraPositionSet(meshhandle,&vertex));
  161.   vertex.x=0,vertex.y=0,vertex.z=0;
  162.   printf("MWLMeshCameraLookAtSet(meshhandle,&vertex)\t\t\t%ld\n",MWLMeshCameraLookAtSet(meshhandle,&vertex));
  163.   vertex.x=0,vertex.y=0,vertex.z=101;
  164.   printf("MWLMeshLightPositionSet(meshhandle,&vertex)\t\t\t%ld\n",MWLMeshLightPositionSet(meshhandle,&vertex));
  165.   color.r=150,color.g=150,color.b=150;
  166.   printf("MWLMeshLightColorSet(meshhandle,&color)\t\t\t\t%ld\n",MWLMeshLightColorSet(meshhandle,&color));
  167.  
  168.   printf("MWLMeshCameraPositionGet(meshhandle,&vertex)\t\t\t");
  169.   retval=MWLMeshCameraPositionGet(meshhandle,&vertex);
  170.   if(retval==RCNOERROR) printf("%g %g %g\n",vertex.x,vertex.y,vertex.z);
  171.   else printf("%ld\n",retval);
  172.   printf("MWLMeshCameraLookAtGet(meshhandle,&vertex)\t\t\t");  
  173.   retval=MWLMeshCameraLookAtGet(meshhandle,&vertex);
  174.   if(retval==RCNOERROR) printf("%g %g %g\n",vertex.x,vertex.y,vertex.z);
  175.   else printf("%ld\n",retval);
  176.   printf("MWLMeshLightPositionGet(meshhandle,&vertex)\t\t\t");
  177.   retval=MWLMeshLightPositionGet(meshhandle,&vertex);
  178.   if(retval==RCNOERROR) printf("%g %g %g\n",vertex.x,vertex.y,vertex.z);
  179.   else printf("%ld\n",retval);
  180.   printf("MWLMeshLightColorGet(meshhandle,&color)\t\t\t\t");
  181.   retval=MWLMeshLightColorGet(meshhandle,&color);
  182.   if(retval==RCNOERROR) printf("%d %d %d\n",color.r,color.g,color.b);
  183.   else printf("%ld\n",retval);
  184.  
  185.   printf("\nSaving in all 3D formats, this means %ld times\n\n",MWL3DFileFormatNumberOfGet());
  186.  
  187.   printf("MWL3DFileFormatNamesGet()\t\t\t\t\t");
  188.   array = MWL3DFileFormatNamesGet();
  189.   if(array!=NULL && array[0]!=NULL) printf("Names found\n");
  190.   else printf("No names found\n");
  191.  
  192.   printf("\n");
  193.   i=0;
  194.   while(array!=NULL && array[i]!=NULL) {
  195.     printf("MWL3DFileFormatIDGet(\"%s\")\t\t\t\t%ld\n",array[i],id=MWL3DFileFormatIDGet(array[i]));
  196.     printf("MWL3DFileFormatExtensionGet(%ld)\t\t\t\t\t%s\n",id,MWL3DFileFormatExtensionGet(id));
  197.  
  198.     sprintf(buffer,"ram:%ld.%s",id,MWL3DFileFormatExtensionGet(id));
  199.  
  200.     printf("MWLMeshSave3D(meshhandle,id,\"%s\",NULL)\t\t\t%ld\n",buffer,MWLMeshSave3D(meshhandle,id,buffer,NULL));
  201.  
  202.     i++;
  203.   }
  204.  
  205.   printf("\nSaving in all 2D formats, this means %ld times\n\n",MWL2DFileFormatNumberOfGet());
  206.  
  207.   printf("Number of drawing modes is %ld\n\n",MWLDrawModeNumberOfGet());
  208.   printf("MWLDrawModeNamesGet()\t\t\t\t\t\t");
  209.   array = MWLDrawModeNamesGet();
  210.   if(array!=NULL && array[0]!=NULL) printf("Names found\n");
  211.   else printf("No names found\n");
  212.  
  213.   if(array!=NULL && array[0]!=NULL) {
  214.     printf("MWLDrawModeIDGet(\"%s\")\t\t\t\t\t%ld\n",array[0],dm=MWLDrawModeIDGet(array[0]));
  215.     
  216.     printf("MWL2DFileFormatNamesGet()\t\t\t\t\t");
  217.     array = MWL2DFileFormatNamesGet();
  218.     if(array!=NULL && array[0]!=NULL) printf("Names found\n");
  219.     else printf("No names found\n");
  220.  
  221.  
  222.     printf("\n");
  223.     i=0;
  224.     while(array!=NULL && array[i]!=NULL) {
  225.       printf("MWL2DFileFormatIDGet(\"%s\")\t\t\t%ld\n",array[i],id=MWL2DFileFormatIDGet(array[i]));
  226.       printf("MWL2DFileFormatExtensionGet(%ld)\t\t\t\t\t%s\n",id,MWL2DFileFormatExtensionGet(id));
  227.  
  228.       sprintf(buffer,"ram:%ld.%s",id,MWL2DFileFormatExtensionGet(id));
  229.  
  230.       printf("MWLMeshSave2D(meshhandle,id,\"%s\",TVWPERSP,dmNULL)\t\t%ld\n",buffer,MWLMeshSave2D(meshhandle,id,buffer,TVWPERSP,dm,NULL));
  231.  
  232.       i++;
  233.     }
  234.   }
  235.   
  236.   printf("\nMWLMeshDelete(meshhandle)\t\t\t\t\t%ld\n",MWLMeshDelete(meshhandle));
  237.   meshhandle=0;
  238. }
  239.